<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>poetry 后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" type="image/ico" href="/images/logo.png"/>

    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layui/css/common.css" media="all">
    <link rel="stylesheet" href="/css/bly-icon.css" media="all">
</head>
<body class="layui-layout-body" style="overflow: auto">
<div class="layui-layout layui-layout-admin">
    <div th:replace="user/common::headerhtml"></div>
    <!--    <div th:replace="user/common::menuhtml"></div>-->
    <div class="layui-container">
        <!-- 内容主体区域 -->
        <div style="padding-top: 15px;color: #666666">
            <div class="layui-fluid layui-col-space15">
                <div class="layui-col-sm6 layui-col-md3">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            访问量
                            <span class="layui-badge layui-bg-blue layui-badge">近30天</span>
                        </div>
                        <div class="layui-card-body layui-card-list">
                            <p class="layui-big-font" id="browseNum">0</p>
                            <p>总计访问量
                                <span class="layui-span-color">
                                    <span id="browseNumTotal">0</span><i class="layui-icon"></i>
                                </span>
                            </p>
                        </div>
                    </div>
                </div>
                <div class="layui-col-sm6 layui-col-md3">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            发布量
                            <span class="layui-badge layui-bg-blue layui-badge">近30天</span>
                        </div>
                        <div class="layui-card-body layui-card-list">
                            <p class="layui-big-font" id="publishNum">0</p>
                            <p>总发布文章量
                                <span class="layui-span-color">
                                    <span id="publishNumTotal">0</span><i class="layui-icon"></i>
                                </span>
                            </p>
                        </div>
                    </div>
                </div>
                <div class="layui-col-sm6 layui-col-md3">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            评论量
                            <span class="layui-badge layui-bg-blue layui-badge">近30天</span>
                        </div>
                        <div class="layui-card-body layui-card-list">
                            <p class="layui-big-font" id="discussNum">0</p>
                            <p>总计评论量
                                <span class="layui-span-color">
                                    <span id="discussNumTotal">0</span> <i class="layui-icon"></i>
                                </span>
                            </p>
                        </div>
                    </div>
                </div>
                <div class="layui-col-sm6 layui-col-md3">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            总计点赞量
                            <!-- <span class="layui-badge layui-bg-blue layui-badge">近30天</span>-->
                        </div>
                        <div class="layui-card-body layui-card-list">
                            <p class="layui-big-font" id="praiseNumTotal">0</p>
                            <p>总计点赞量<span class="layui-span-color"><i class="layui-icon"></i></span></p>
                        </div>
                    </div>
                </div>

                <div class="layui-col-sm12">
                    <div class="layui-card">
                        <div class="layui-card-header">访问量</div>
                        <div class="layui-card-body">
                            <div class="layui-row">
                                <div class="layui-col-sm12">
                                    <div class="layui-carousel layadmin-carousel layadmin-dataview" data-anim="fade"
                                         id="LAY-index-pagetwo" lay-anim="fade" style="width: 100%; height: 280px;">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-sm6">
                        <div class="layui-card">
                            <div class="layui-card-header">最近评论</div>
                            <div class="layui-card-body">
                                <table class="layui-table layui-page-table" lay-skin="line">
                                    <thead>
                                    <tr>
                                        <th>用户名</th>
                                        <th>最后登录时间</th>
                                        <th>评论内容</th>
                                        <th>获得赞</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <!--<tr>
                                        <td><span class="first">胡歌</span></td>
                                        <td><i class="layui-icon layui-icon-log"> 11:20</i></td>
                                        <td><span>在线</span></td>
                                        <td>22 <i class="layui-icon layui-icon-praise"></i></td>
                                    </tr>-->
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-sm6">
                        <div class="layui-card">
                            <div class="layui-card-header">最近留言</div>
                            <div class="layui-card-body">
                                <ul class="layui-card-status layui-home2-usernote">
                                    <!--<li>
                                        <h3>贤心</h3>
                                        <p>作为 layui 官方推出的后台模板，从初版的饱受争议，到后续的埋头丰富，逐步占据了国内后台系统应用的主要市场。</p>
                                        <span>5月30日 00:00</span>
                                        <a href="javascript:;" layadmin-event="replyNote" data-id="7"
                                           class="layui-btn layui-btn-xs layui-reply">回复</a>
                                    </li>
                                    -->
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div th:replace="user/common::footerhtml"></div>
</div>
<script src="/layui/layui.js" charset="utf-8"></script>
<script src="/layui/menu.js" charset="utf-8"></script>
<script src="/js/jquery.min.js" charset="utf-8"></script>
<script src="/js/echarts.min.js"></script>

<script type="text/javascript">
    layui.use('element', function () {

        init();

        function init() {
            $.ajax({
                url: '../user/getBaseData',
                type: 'post',
                dataType: 'json',
                success: function (res) {
                    if (res.status != 200) {
                        layer.msg('数据加载失败！');
                        return;
                    }
                    var data = res.data;

                    $('#publishNum').text(data.publishNum || 0);
                    $('#publishNumTotal').text(data.publishNumTotal || 0);
                    $('#browseNum').text(data.browseNum || 0);
                    $('#browseNumTotal').text(data.browseNumTotal || 0);
                    $('#praiseNum').text(data.praiseNum || 0);
                    $('#praiseNumTotal').text(data.praiseNumTotal || 0);
                    $('#discussNum').text(data.discussNum || 0);
                    $('#discussNumTotal').text(data.discussNumTotal || 0);

                    var xAdata = [];
                    var sedata = [];
                    if (data.browseList) {
                        $.each(data.browseList, function (i, it) {
                            xAdata.push(it.date);
                            sedata.push(it.value)
                        })
                    }
                    var myChart = echarts.init(document.getElementById('LAY-index-pagetwo'));
                    var option = {
                        grid: {
                            left: '3%',
                            right: '4%',
                            bottom: '3%',
                            top: '10%',
                            containLabel: true
                        },
                        tooltip: {
                            trigger: 'axis'
                        },
                        xAxis: {
                            type: 'category',
                            data: xAdata,
                            axisLabel: {
                                interval: 0,
                                rotate: 40
                            }
                        },
                        yAxis: {
                            type: 'value'
                        },
                        series: [{
                            data: sedata,
                            type: 'line',
                            smooth: true,
                            itemStyle: {
                                normal: {
                                    color: "#2ec7c9",
                                    lineStyle: {
                                        color: "#2ec7c9"
                                    }
                                }
                            }
                        }]
                    };
                    myChart.setOption(option);
                }
            });
        }
    });
</script>
</body>